package cyc.learn.mode.observable;

import java.util.Observable;
import java.util.Observer;

public class Customer implements Observer {
    private String name;

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    @Override
    public void update(Observable o, Object arg) {
        if (o instanceof Food && arg instanceof Float){
            Food food = (Food) o;
            float price = (float) arg;
            System.out.println("您好：" + this.name + " ," + food.getName() + "的价格已经发生改变，现在的价格为：" + price + "元/斤");
        }
    }
}
